home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.Accessible;
- import com.sun.java.accessibility.AccessibleContext;
- import java.awt.AWTEvent;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.LayoutManager;
- import java.awt.event.InputEvent;
- import java.awt.event.KeyEvent;
- import java.awt.event.WindowEvent;
- import java.util.Vector;
-
- public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer {
- private int defaultCloseOperation = 1;
- protected JRootPane rootPane;
- protected boolean rootPaneCheckingEnabled = false;
- protected AccessibleContext accessibleContext = null;
-
- public JFrame() {
- this.frameInit();
- }
-
- public JFrame(String title) {
- super(title);
- this.frameInit();
- }
-
- protected void addImpl(Component comp, Object constraints, int index) {
- if (this.isRootPaneCheckingEnabled()) {
- throw this.createRootPaneException("add");
- } else {
- super.addImpl(comp, constraints, index);
- }
- }
-
- protected JRootPane createRootPane() {
- return new JRootPane();
- }
-
- private Error createRootPaneException(String op) {
- String type = this.getClass().getName();
- return new Error("Do not use " + type + "." + op + "() use " + type + ".getContentPane()." + op + "() instead");
- }
-
- protected void frameInit() {
- ((Component)this).enableEvents(72L);
- this.setRootPane(this.createRootPane());
- ((Component)this).setBackground(UIManager.getColor("control"));
- this.setRootPaneCheckingEnabled(true);
- }
-
- public AccessibleContext getAccessibleContext() {
- if (this.accessibleContext == null) {
- this.accessibleContext = new AccessibleJFrame(this);
- }
-
- return this.accessibleContext;
- }
-
- public Container getContentPane() {
- return this.getRootPane().getContentPane();
- }
-
- public int getDefaultCloseOperation() {
- return this.defaultCloseOperation;
- }
-
- public Component getGlassPane() {
- return this.getRootPane().getGlassPane();
- }
-
- public JMenuBar getJMenuBar() {
- return this.getRootPane().getMenuBar();
- }
-
- public JLayeredPane getLayeredPane() {
- return this.getRootPane().getLayeredPane();
- }
-
- public JRootPane getRootPane() {
- return this.rootPane;
- }
-
- protected boolean isRootPaneCheckingEnabled() {
- return this.rootPaneCheckingEnabled;
- }
-
- protected void processKeyEvent(KeyEvent e) {
- super.processKeyEvent(e);
- if (!((InputEvent)e).isConsumed()) {
- JComponent.processKeyBindingsForAllComponents(e, this, new Vector(), ((AWTEvent)e).getID() == 401);
- }
-
- }
-
- protected void processWindowEvent(WindowEvent e) {
- super.processWindowEvent(e);
- if (((AWTEvent)e).getID() == 201) {
- switch (this.defaultCloseOperation) {
- case 0:
- default:
- break;
- case 1:
- ((Component)this).setVisible(false);
- break;
- case 2:
- ((Component)this).setVisible(false);
- ((Frame)this).dispose();
- }
- }
-
- }
-
- public void setContentPane(Container contentPane) {
- this.getRootPane().setContentPane(contentPane);
- }
-
- public void setDefaultCloseOperation(int operation) {
- this.defaultCloseOperation = operation;
- }
-
- public void setGlassPane(Component glassPane) {
- this.getRootPane().setGlassPane(glassPane);
- }
-
- public void setJMenuBar(JMenuBar menubar) {
- this.getRootPane().setMenuBar(menubar);
- }
-
- public void setLayeredPane(JLayeredPane layeredPane) {
- this.getRootPane().setLayeredPane(layeredPane);
- }
-
- public void setLayout(LayoutManager manager) {
- if (this.isRootPaneCheckingEnabled()) {
- throw this.createRootPaneException("setLayout");
- } else {
- super.setLayout(manager);
- }
- }
-
- protected void setRootPane(JRootPane root) {
- if (this.rootPane != null) {
- ((Container)this).remove(this.rootPane);
- }
-
- this.rootPane = root;
- if (this.rootPane != null) {
- boolean checkingEnabled = this.isRootPaneCheckingEnabled();
-
- try {
- this.setRootPaneCheckingEnabled(false);
- ((Container)this).add(this.rootPane, "Center");
- } finally {
- this.setRootPaneCheckingEnabled(checkingEnabled);
- }
- }
-
- }
-
- protected void setRootPaneCheckingEnabled(boolean enabled) {
- this.rootPaneCheckingEnabled = enabled;
- }
-
- public void update(Graphics g) {
- ((Container)this).paint(g);
- }
- }
-